package com.xintai.system.service.impl;

import java.util.List;

import com.xintai.utils.MyPingYinUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xintai.system.mapper.ErpClientMapper;
import com.xintai.system.domain.ErpClient;
import com.xintai.system.service.IErpClientService;

/**
 * 客户Service业务层处理
 * 
 * @author xintai
 * @date 2021-01-12
 */
@Service
public class ErpClientServiceImpl implements IErpClientService 
{
    @Autowired
    private ErpClientMapper erpClientMapper;

    /**
     * 查询客户
     * 
     * @param cId 客户ID
     * @return 客户
     */
    @Override
    public ErpClient selectErpClientById(Integer cId)
    {
        return erpClientMapper.selectErpClientById(cId);
    }

    @Override
    public boolean verifyErpClientName(ErpClient erpClient) {
        return erpClientMapper.verifyErpClientName(erpClient);
    }

    /**
     * 查询客户列表
     * 
     * @param erpClient 客户
     * @return 客户
     */
    @Override
    public List<ErpClient> selectErpClientList(ErpClient erpClient)
    {
        return erpClientMapper.selectErpClientList(erpClient);
    }

    /**
     * 新增客户
     * 
     * @param erpClient 客户
     * @return 结果
     */
    @Override
    public int insertErpClient(ErpClient erpClient)
    {
        erpClient.setcJm(MyPingYinUtil.getFirstSpell(erpClient.getcName()));
        return erpClientMapper.insertErpClient(erpClient);
    }

    /**
     * 修改客户
     * 
     * @param erpClient 客户
     * @return 结果
     */
    @Override
    public int updateErpClient(ErpClient erpClient)
    {
        erpClient.setcJm(MyPingYinUtil.getFirstSpell(erpClient.getcName()));
        return erpClientMapper.updateErpClient(erpClient);
    }

    /**
     * 批量删除客户
     * 
     * @param cIds 需要删除的客户ID
     * @return 结果
     */
    @Override
    public int deleteErpClientByIds(Integer[] cIds)
    {
        return erpClientMapper.deleteErpClientByIds(cIds);
    }

    /**
     * 删除客户信息
     * 
     * @param cId 客户ID
     * @return 结果
     */
    @Override
    public int deleteErpClientById(Integer cId)
    {
        return erpClientMapper.deleteErpClientById(cId);
    }
}
